import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from 'redux';
import Counter from './components/Counter';
import reducer from "./reduces/index";

const app = document.createElement('div');
app.className = "wrap";

//使用redux管理数据
const store = createStore(reducer);//  need a ininital reducer action
document.body.appendChild(app);
const render = () => {
    ReactDOM.render(<Counter
        value={store.getState()}
        onIncrement={() => { store.dispatch({ type: "INCREMENT" }) } }
        onDecrement={() => { store.dispatch({ type: "DECREMENT" }) } }
        />, app);
}
render();
store.subscribe(render)



